const ProxyStore = require('./store/proxyStore');
const pathToTitle = require('./pathToTitle');
const shareLogo = require('./shareLogo');
const icon = require('./icon');
let store = new ProxyStore({
  state: {
    icon
  },
  methods: {
    jumpNextPage(e){
      let url = e.currentTarget.dataset.url;
      wx.navigateTo({url})
    },
    commonClickMethod(e){
      let name = e.currentTarget.dataset.name;
      name && this[name] && this[name](e);
    }
  },
  pageListener: {
    onShareAppMessage(){
      let path = this.route || 'pages/index/index';
      let title = pathToTitle[`../../${path}`] || 'WX-RUI小程序示例';
      let url = `http://read.yajunliang.com/api/wechat/qrcode?path=${path}`;
      let imageUrl = [...shareLogo, url];
      imageUrl = imageUrl[Math.floor((Math.random() * imageUrl.length))];
      return {
        title,
        path,
        imageUrl
      }
    },
  }
})
module.exports = store;